home *** CD-ROM | disk | FTP | other *** search
/ IRIX Patches 1995 September / SGI IRIX Patches 1995 Sep.iso / 5.3_patches / patchSG0000665 / patchSG0000665.idb / usr / include / sys / shmiq.h.z / shmiq.h
C/C++ Source or Header  |  1995-09-07  |  7KB  |  196 lines

  1. #ifndef __SYS_SHMIQ_H__
  2. #define __SYS_SHMIQ_H__
  3.  
  4. /**************************************************************************
  5.  *                                      *
  6.  *        Copyright ( C ) 1990, Silicon Graphics, Inc.          *
  7.  *                                      *
  8.  *  These coded instructions, statements, and computer programs  contain  *
  9.  *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
  10.  *  are protected by Federal copyright law.  They  may  not be disclosed  *
  11.  *  to  third  parties  or copied or duplicated in any form, in whole or  *
  12.  *  in part, without the prior written consent of Silicon Graphics, Inc.  *
  13.  *                                      *
  14.  **************************************************************************/
  15. /*
  16.  * Internals for the shared memory input queue driver
  17.  */
  18. #ident "$Revision: 1.20 $"
  19.  
  20. #include "sys/types.h"
  21. #include "sys/poll.h"
  22.  
  23. /*
  24.  * The data is ALMOST never interpreted.  The exception is for cursor
  25.  * tracking.    If the type field is '0' (IDEV_PTR_EVENT), then
  26.  * u.ptraxis[0] and u.ptraxis[1] contain pointer coordinates which
  27.  * are sent to the "setscr" stuff designated stream.
  28.  */
  29. struct shmqdata {
  30.     unsigned char device ;        /* device major */
  31.     unsigned char which ;        /* device minor */
  32.     unsigned char type ;        /* event type */
  33.     unsigned char flags ;        /* little event data */
  34.     union {
  35.         long int pos ;        /* big event data */
  36.         short ptraxis[2] ;        /* event data for PTR events */
  37.     } un;
  38. } ;
  39.  
  40. /* Data structure for intra-kernel verification ( addressability ) */
  41. struct shmiqlinkid {
  42.     short int devminor ;    /* Identifies the shmiq */
  43.     short int index ;    /* Identifies the device */
  44. } ;
  45.  
  46. struct shmqevent {
  47.     union {
  48.         long int time ;        /* 10 millisecond units from lbolt */
  49.         struct shmiqlinkid id ;
  50.     } un ;
  51.     struct shmqdata data ;
  52. } ;
  53.  
  54. struct sharedMemoryInputQueue {
  55.     volatile long int head ;        /* user's index into events */
  56.     volatile long int tail ;        /* kernel's index into events */
  57.     volatile unsigned long int flags ;    /* place for out-of-band data */
  58.     struct shmqevent events[1] ;        /* input event buffer */
  59. } ;
  60. /* flags' bits */
  61. #define SHMIQ_OVERFLOW    0x00000001
  62. #define SHMIQ_CORRUPTED 0x00000002
  63.  
  64. #ifdef _KERNEL
  65.  
  66. /* At "I_LINK" time, a M_PCPROTO message with this is sent to the lower
  67.  * stream to see if he plays by the "shmiq" rules.  The correct response
  68.  * is to "qreply" with a M_PCPROTO with "mtype" changed from "SHMIQ_NOTICE"
  69.  * to "SHMIQ_PLAY".
  70.  */
  71. #define SHMIQ_NOTICE ( ( 'S' << 24 ) | ( 'H' << 16 ) | ( 'M' << 8 ) | 'Q' )
  72. #define SHMIQ_PLAY   ( 'S' | ( 'H' << 8 ) | ( 'M' << 16 ) | ( 'Q' << 24 ) )
  73. struct shmqntc {
  74.     unsigned long int mtype ;
  75.     struct shmiqlinkid id ;
  76. } ;
  77.  
  78. struct cursorTrack { /* Used for kernel cursor tracking */
  79.     int status ;
  80.     long int x ;        /* cursor X */
  81.     long int y ;        /* cursor Y */
  82.     /* We can't filter at the source or the locator won't move */
  83.     long int filterULX ;    /* don't care box minimum cursor X */
  84.     long int filterULY ;    /* don't care box minimum cursor Y */
  85.     long int filterLRX ;    /* don't care box maximum cursor X */
  86.     long int filterLRY ;    /* don't care box maximum cursor Y */
  87. } ;
  88.  
  89. struct shmq {
  90.     struct sharedMemoryInputQueue *q ; /* kernel space pointer */
  91.     long int qtail ;        /* private copy the user can't break */
  92.     long int qsize ;        /* record at attach time */
  93.     struct proc *owner ;        /* proccess attached to */
  94.     struct shaddr_s *sowner ;    /* share group attached to */
  95.     caddr_t user_vaddr ;        /* location in owner's proccess space */
  96. } ;
  97.  
  98. /* Chain for "I_LINK"'ed lower streams */
  99. struct shmiqlink {
  100.     struct shmiq *up ;
  101.     struct shmiqlinkid id ;
  102.     queue_t *lwq ;        /* top write queue of lower stream */
  103.     queue_t *lrq ;        /* top read queue of lower stream */
  104.     struct shmiq *mux ;
  105.     int l_index ;        /* system ID from struct linkblk */
  106.     int l_flags ;        /* flags specific to this device */
  107. } ;
  108.  
  109. struct shmiq {
  110.     /* Event Queue stuff */
  111.     struct shmq qd ;        /* Connection data for user's queue */
  112.     struct cursorTrack locator ;    /* Used for kernel cursor tracking */
  113.     unsigned int currentScreen ;    /* Where to send cursor motion */
  114.     time_t lastEventTime ;        /* time (in ticks) of last event */
  115.  
  116.     /* Streams stuff */
  117.     queue_t *urq ;            /* top read queue of upper stream */
  118. #define MAX_MUX_LINKS 16 /* Should be a dynamic parameter, but ... */
  119.     struct shmiqlink *linkrecord[MAX_MUX_LINKS] ;
  120.  
  121.     /* spin lock for access */
  122.     lock_t alck ;            /* always acquired by "trading" */
  123.                     /* for the "shmiq_lock" */
  124.  
  125.     /* Misc. Std. Driver stuff */
  126.     int status ;
  127. /* possible status values -- OR'ed together */
  128. #define SHMIQ_STR_INIT 1
  129. #define SHMIQ_CHAR_INIT    2
  130.  
  131.     int stroflag ;
  132.     int deviceminor ;        /* To find our way back */
  133.     struct pollhead selproc ;        /* For selwakeup */
  134. } ;
  135.  
  136. struct shmiqdev {
  137.     struct shmiq    *qptr ;        /* queue for this minor device */
  138.     int drained ;            /* queue drained flag for poll(2) */
  139. } ;
  140.  
  141. /* Stuff from master.d/shmiq */
  142. extern int shmiq_cnt ; /* Actual number */
  143. extern lock_t shmiq_lock ; /* Controls all access to the array */
  144. extern struct shmiqdev dev_shmiq[] ;
  145.  
  146. #define SHMIQ_POSCURSOR ( ( 'S' << 24 ) | ( 'H' << 16 ) | ( 'I' << 8 ) | 'Q' )
  147.  
  148. #endif /* _KERNEL */
  149.  
  150. /* USER VISIBLE */
  151. #define SHMIQ_MINSIZE 100 /* Minimum size of queue in number of events */
  152.  
  153. struct muxioctl {    /* for QIOCMUXIOC */
  154.     int index ;    /* index of lower stream */
  155.     int realcmd ;    /* subdevice IOCTL command */
  156. } ;
  157.  
  158. struct shmiqreq {        /* for QIOCATTACH */
  159.     char *user_vaddr ;    /* starting address to lock down for a shmiq */
  160.     int arg ;        /* size of queue event array */
  161. } ;
  162.  
  163. #define    SHMIQ_LINK_CURSX    0x1
  164. #define    SHMIQ_LINK_CURSY    0x2
  165. #define    SHMIQ_LINK_CURSOR    0x3
  166. struct shmiqsetcurs {    /* for QIOCSETCURS */
  167.     short index ;    /* index of device */
  168.     short axes ;    /* axes we care about (SHMIQ_LINK_CURS[XY]) */
  169. } ;
  170.  
  171. struct shmiqsetcpos {    /* for QIOCSETCPOS */
  172.     short    x ;
  173.     short    y ;
  174. } ;
  175.  
  176. /* ioctl cmds */
  177. #define QIOCATTACH    _IOW('Q',1,struct shmiqreq)    /* map memory */
  178. #define QIOCDETACH    _IO('Q',2)            /* unmap memory */
  179. #define QIOCSERVICED    _IO('Q',3)        /* acknowledge overflow */
  180. #define QIOCURSTRK    _IOW('Q',4,int)        /* set cursor tracking mode */
  181. #define QIOCURSIGN    _IOW('Q',5,long int[4])    /* set cursor filter box */
  182. #define QIOCSETSCRN    _IOW('Q',6,int)        /* set curent screen */
  183. #define QIOCIISTR    _IOW('Q',7, struct muxioctl)/* double indirect I_STR */
  184. #define QIOCGETINDX    _IOWR('Q',8,int)    /* get index from l_index */
  185. #define    QIOCSETCURS    _IOWR('Q',9,struct shmiqsetcurs ) /* set cursor axes */
  186. #define    QIOCSETCPOS    _IOWR('Q',10,struct shmiqsetcpos ) /* set cursor position */
  187. #define    QIOCGETITIME    _IOR('Q',11,time_t)    /* get time since last event */
  188.  
  189. /* QIOCURSTRK mode values -- or'ed together */
  190. #define SHMIQ_CURSOR_TRACKED 1
  191. #define SHMIQ_CURSOR_ASYNC 2    /* Tracks physical device */
  192. #define SHMIQ_CURSOR_SYNC  0    /* Tracks logical device */
  193. #define SHMIQ_CURSOR_FILTER 4    /* use ignore box ? (arm trigger) */
  194.  
  195. #endif /* __SYS_SHMIQ_H__ */
  196.